package sample.user.service.consumer;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

import sample.data.sqlite.entity.user.UserEntity;
import sample.user.consumer.data.UserDataConsumer;


@Service
public class UserServiceConsumer {
	
	private final Logger logger = LoggerFactory.getLogger(this.getClass()); 

	@Autowired
	private UserDataConsumer userDataConsumer;

	public String getUser() {
		
		List<UserEntity> userEntities = userDataConsumer.getUser();
		
		ObjectMapper objectMapper = new ObjectMapper();
		String result = "";
		try {
			result = objectMapper.writeValueAsString(userEntities);
		} catch (JsonProcessingException e) {
			e.printStackTrace();
		}
		
		return result;
	}
}
